package com.kinglone.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.kinglone.dao.RegionStateMapper;
import com.kinglone.model.RegionState;
import com.kinglone.service.RegionStateService;

@Service("regionStateService")
public class RegionStateServiceImpl implements RegionStateService{

	@Resource
	private RegionStateMapper regionStateDao;
	
	@Override
	public List<RegionState> getRegionStateListByParentId(String parentid) {
		
		return this.regionStateDao.getRegionStateListByParentId(parentid);
	}

	@Override
	public List<RegionState> getCityListByProvinceID(String provinceID) {
		
		return this.regionStateDao.getCityListByProvinceID(provinceID);
	}

	@Override
	public List<RegionState> getAreaListByCityID(String cityID) {
		
		return this.regionStateDao.getAreaListByCityID(cityID);
	}

	@Override
	public String selAddrByAreaID(String areaID) {
		String addr ="";
		//查询区
		RegionState area = regionStateDao.getAreaById(areaID);
		if(area != null){
			//查询市
			RegionState city = regionStateDao.getCityById(area.getParent());
			if(city != null){
				//查询省
				RegionState province =regionStateDao.getProvinceById(city.getParent());
				if(province != null){
					addr = province.getRegionstateName()+""+city.getRegionstateName()+""+area.getRegionstateName();
				}
			}
		}
		
		return addr;
	}

}
